<%--                                                                       --%>
<%-- Copyright (c) 2004-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<script language="JavaScript">

//
//
//
function doChannelSelect() {
  var selectedIds = "";
  for (var index = 0; index < document.epProgramForm.parentChannels.length; index++) {
    selectedIds += document.epProgramForm.parentChannels.options[index].value + ";";
  }
  doPickerPopupAction('<c:url value="/mt/categoryPickerPopupMultiSelect.do"/>', 'setParentChannels', 301, null, selectedIds, null);
}

//
//
//
function setParentChannels(ids, names) {
  document.epProgramForm.parentChannels.length = 0;
  for (var index = 0; index < ids.length; index++) {
    var option = new Option(" ");
    option.text = names[index];
    option.value = ids[index];
    document.epProgramForm.parentChannels.options[index] = option;
  }

  document.epProgramForm.primaryParentId.length = 0;
  for (var index = 0; index < ids.length; index++) {
    var option = new Option(" ");
    option.text = names[index];
    option.value = ids[index];
    document.epProgramForm.primaryParentId.options[index] = option;
  }
}

//
//
//
function doSubmit(form) {
  var size = form.parentChannels.length;

  for (var index = 0; index < size ; index++) {
    form.parentChannels.options[index].selected = true;
  }

  return validateForm(form);
}

//
//
//
function doCancel(form) {
  form.action = "<c:url value="/ep/cancel.do"/>";
  form.submit();
}

//
//
//
function doSave(form) {
  form.action = "<c:url value="/ep/programSave.do"/>";
  form.submit();
}

</script>

<%@include file="/mt/common/pickerPopupHelper.jsp" %>

<html-el:javascript formName="epProgramForm" method="validateForm"/>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle">
<c:if test="${epProgramForm.map.id == 0}">
      <bean-el:message key="ep.program.new.page.title" bundle="ep.messages"/>
</c:if>
<c:if test="${epProgramForm.map.id != 0}">
      <bean-el:message key="ep.program.edit.page.title" bundle="ep.messages" arg0="${epProgramEditView.map.name}"/>
</c:if>
      </div>
      <div class="errorMessage"><html-el:errors bundle="ep.messages"/></div>
      <%@ include file="/mc/common/pagetab.jsp" %>

      <div class="breadcrumb">
      <c:if test="${not empty epProgramEditView.map.breadcrumbs}">
        <bean:size id="len" name="epProgramEditView" property="breadcrumbs"/>
        <c:forEach var="channel" items="${epProgramEditView.map.breadcrumbs}" varStatus="index">
          <c:url var="browseUrl" value="/ep/channelBrowse.do">
            <c:param name="channelId" value="${channel.map.id}"/>
          </c:url>
          <c:if test="${index.count > 1}"><bean-el:message key="ep.breadcrumb.delimiter" bundle="ep.messages"/>&nbsp;</c:if><c:if test="${index.count != len}"><!--a href="<c:out value="${browseUrl}"/>"--></c:if><c:out value="${channel.map.name}"/><c:if test="${index.count != len}"><!--/a--></c:if>
        </c:forEach>
      </c:if>
      </div>

      <!- place body here -->

      <html-el:form action="/ep/programNext.do" focus="name" onsubmit="return doSubmit(this);">

      <html-el:hidden property="programId" value="${epProgramForm.map.id}"/>
      <html-el:hidden property="channelId" value="${epProgramEditView.map.channelId}"/>
      <input type="hidden" name="ctx.f" value="<c:out value="${requestScope['ctx.f']}"/>"/>

      <html-el:hidden property="startType"/>
      <html-el:hidden property="srcType"/>
      <html-el:hidden property="srcContentType"/>
      <html-el:hidden property="srcId"/>
      <html-el:hidden property="scriptPath"/>
      <html-el:hidden property="embedScriptPath"/>
      <html-el:hidden property="urlPath"/>
      <html-el:hidden property="publishCategoryId"/>
      <html-el:hidden property="processOID"/>
      <html-el:hidden property="subCatIncluded"/>
      <html-el:hidden property="showOnlyReadable"/>
      <html-el:hidden property="programDisplayTemplateId"/>
      <html-el:hidden property="contentDisplayTemplateId"/>
      <html-el:hidden property="cacheable"/>
      <html-el:hidden property="timeout"/>

      <div class="pageSubtitle">
        <span class="left"><bean-el:message key="ep.program.information" bundle="ep.messages"/></span>
        <span class="right">&nbsp;</span>
      </div>

      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="label"><bean-el:message key="ep.program.name" bundle="ep.messages"/>:*</td>
        <td class="labelField"><html-el:text size="40" maxlength="80" property="name"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean-el:message key="ep.program.display.name" bundle="ep.messages"/>:</td>
        <td class="labelField"><html-el:text size="40" maxlength="100" property="displayName"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean-el:message key="ep.description" bundle="ep.messages"/>:</td>
        <td class="labelField"><html-el:textarea rows="5" cols="50" property="description"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean-el:message key="ep.status" bundle="ep.messages"/>:*</td>
        <td class="labelField"><html-el:radio property="status" value="1"/><bean-el:message key="ep.status.online" bundle="ep.messages"/>&nbsp;<html-el:radio property="status" value="0"/><bean-el:message key="ep.status.offline" bundle="ep.messages"/>
        </td>
      </tr>

<c:if test="${epProgramEditView.map.showNavigable}">
      <tr>
        <td class="label"><bean-el:message key="ep.navigable" bundle="ep.messages"/>:*</td>
        <td class="labelField">
		<html-el:radio property="navigable" value="0"/><bean-el:message key="ep.yes" bundle="ep.messages"/>
		<html-el:radio property="navigable" value="1"/><bean-el:message key="ep.no" bundle="ep.messages"/>
        </td>
      </tr>
</c:if>

      <tr>
        <td class="label"><bean-el:message key="ep.program.manager.name" bundle="ep.messages"/>:</td>
        <td class="labelField"><html-el:text size="40" maxlength="80" property="mgrName"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean-el:message key="ep.program.manager.email" bundle="ep.messages"/>:</td>
        <td class="labelField"><html-el:text size="40" maxlength="80" property="mgrEmail"/>
        </td>
      </tr>

      <bean:size id="numberOfParentChannels" name="epProgramEditView" property="parentChannels"/>

      <tr>
        <td class="label"><bean-el:message key="ep.program.parent.channels" bundle="ep.messages"/>:<c:if test="${numberOfParentChannels > 0}">*</c:if></td>
        <td class="labelField">
        <table>
        <tr>
          <td>
          <html-el:select multiple="true" size="3" property="parentChannels">
          <html-el:optionsCollection name="epProgramEditView" property="parentChannels" value="id" label="name"/>
          </html-el:select>
          </td>
          <td valign="top">
          <input type=button class="pageButton" value="<bean-el:message key="button.browse" bundle="ep.messages"/>" onclick="doChannelSelect()">
          </td>
        </tr>
        </table>
        </td>
      </tr>

      <tr>
        <td class="label"><bean-el:message key="ep.program.primary.parent.channel" bundle="ep.messages"/>:<c:if test="${numberOfParentChannels > 0}">*</c:if></td>
        <td class="labelField">
          <html-el:select property="primaryParentId">
          <html-el:optionsCollection name="epProgramEditView" property="parentChannels" value="id" label="name"/>
          </html-el:select>
        </td>
      </tr>

      </table>

      <div class="pageButtonWrap" align="right">
        <input type="reset" name="resetBtn" value="<bean-el:message key='button.reset' bundle="ep.messages"/>" class="inputButton">
        &nbsp;&nbsp;
        <input type="button" name="cancelData" class="inputButton" value="<bean-el:message key='button.cancel' bundle="ep.messages"/>" onclick="doCancel(this.form);">
<c:if test="${0 != 0 && epProgramForm.map.id == 0}">
        <input type="button" name="saveData" class="inputButton" value="<bean-el:message key='button.save' bundle="ep.messages"/>" onclick="doSave(this.form)">
</c:if>
<c:if test="${epProgramForm.map.id == 0}">
        <input type="submit" name="saveData" class="inputButton" value="<bean-el:message key='button.next' bundle="ep.messages"/>">
</c:if>
<c:if test="${epProgramForm.map.id != 0}">
        <input type="submit" name="saveData" class="inputButton" value="<bean-el:message key='button.save' bundle="ep.messages"/>">
</c:if>
      </div>

      </html-el:form>

    </td>
  </tr>
</table>
